package rpc_client

import (
	"context"
	"github.com/sirupsen/logrus"
	"github.com/smallnest/rpcx/client"
	"go.web.demo.com/api/entity"
	"go.web.demo.com/api/pojo"
)

var patientClient client.XClient

//初始化
func createPatientClient() {
	logrus.Info("创建PatientClient")
	patientClient = client.NewXClient("PatientService", client.Failtry, client.RandomSelect, discover, client.DefaultOption)
}

// ClosePatientClient 关闭客户端
func ClosePatientClient() {
	logrus.Info("关闭PatientClient")
	e := patientClient.Close()
	if e != nil {
		logrus.Error(e)
		panic(e)
	}
	patientClient = nil
}

// QueryPatientList 查询用户
func QueryPatientList() []entity.Patient {
	slice := make([]entity.Patient, 0, 16)
	e := patientClient.Call(context.Background(), "QueryList", &pojo.PatientParam{}, &slice)
	if e != nil {
		logrus.Error(e)
		panic(e)
	}
	return slice
}
